﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GLWrap.MathExt;
using Sharp3D.Math.Core;
using Tao.OpenGl;

namespace GLWrap
{
    public class Material
    {
        public Vector4F Ambient { get; set; }
        public Vector4F Diffuse { get; set; }
        public Vector4F Specular { get; set; }
        public Vector4F Emission { get; set; }
        public float Shininess;

        public void ApplyMaterial()
        {
            ApplyVectorMaterialParam(Gl.GL_AMBIENT, Ambient);
            ApplyVectorMaterialParam(Gl.GL_DIFFUSE, Diffuse);
            ApplyVectorMaterialParam(Gl.GL_SPECULAR, Specular);
            ApplyVectorMaterialParam(Gl.GL_EMISSION, Emission);
            ApplyScalarMaterialParam(Gl.GL_SHININESS, Shininess);
        }

        private static void ApplyVectorMaterialParam(int pName,Vector4F vParams)
        {
            Gl.glMaterialfv(Gl.GL_FRONT,pName,vParams.GetArray());
        }

        private static void ApplyScalarMaterialParam(int pName,float value)
        {
            Gl.glMaterialf(Gl.GL_FRONT,pName,value);
        }
    }
}
